//引入一级路由组件
// import Home from '@/pages/Home'
// import Search from '@/pages/Search'
// import Login from '@/pages/Login'
// import Register from '@/pages/Register'
// import Detail from "@/pages/Detail"
// import AddCartSuccess from "@/pages/AddCartSuccess"
// import ShopCart from "@/pages/ShopCart"
// import Trade from "@/pages/Trade"
// import Pay from "@/pages/Pay"
// import PaySuccess from "@/pages/PaySuccess"
// import Center from "@/pages/Center"
// //引入二级路由
// import MyOrder from "@/pages/Center/myOrder"
// import GroupOrder from "@/pages/Center/groupOrder"

//路由配置信息
export default [
    {
        name: 'home',
        path: "/home",
        component: ()=>import('@/pages/Home'), //路由懒加载
        meta: {
            isShowFooter: true,
            needUserInfo: false
        }
    },
    {
        name: 'search',
        path: "/search/:keyword?",
        component: ()=>import('@/pages/Search'),//路由懒加载
        meta: {
            isShowFooter: true,
            needUserInfo: false

        },

    },
    {
        name: 'login',
        path: "/login",
        component: ()=>import('@/pages/Login'),
        meta: {
            isShowFooter: false,
            needUserInfo: false
        }
    },
    {
        name: 'register',
        path: "/register",
        component: ()=>import('@/pages/Register'),
        meta: {
            isShowFooter: false,
            needUserInfo: false

        }
    },
    {
        name: 'detail',
        path: "/detail/:skuid",
        component:  ()=>import("@/pages/Detail"),
        meta: {
            isShowFooter: true,
            needUserInfo: false

        }
    },
    {
        name: 'addcartsuccess',
        path: "/addcartsuccess",
        component:  ()=>import("@/pages/AddCartSuccess"),
        meta: {
            isShowFooter: true,
            needUserInfo: false

        }
    },
    {
        name: 'shopcart',
        path: "/shopcart",
        component:  ()=>import("@/pages/ShopCart"),
        meta: {
            isShowFooter: true,
            needUserInfo: false

        }
    },
    {
        name: 'trade',
        path: "/trade",
        component:  ()=>import("@/pages/Trade"),
        meta: {
            isShowFooter: true,
            needUserInfo: true
        },
        //路由独享守卫
        beforeEnter(to, from, next) {
            //要去交易页页面必须从购物车跳转
            if (from.path == '/shopcart') {
                next()
            } else {
               next(false)
            }
        }
    },
    {
        name: 'pay',
        path: "/pay",
        component:  ()=>import("@/pages/Pay"),
        meta: {
            isShowFooter: true,
            needUserInfo: true
        },
        //路由独享守卫
        beforeEnter(to, from, next) {
            //要去交易页页面必须从购物车跳转
            if (from.path == '/trade') {
                next()
            } else {
               next(false)
            }
        }
    },
    {  
        name: 'paysuccess',
        path: "/paysuccess",
        component:  ()=>import("@/pages/PaySuccess"),
        meta: {
            isShowFooter: true,
            needUserInfo: true
        },
        //路由独享守卫
        beforeEnter(to, from, next) {
            //要去交易页页面必须从购物车跳转
            if (from.path == '/pay') {
                next()
            } else {
               next(false)
            }
        }
    },
    {
        name: 'center',
        path: "/center",
        component:  ()=>import("@/pages/Center"),
        meta: {
            isShowFooter: true,
            needUserInfo: true
        },
        children: [
            {
                path: 'myOrder',
                component:  ()=>import("@/pages/Center/myOrder"),
                meta: {
                    needUserInfo: true
                }
            },
            {
                path: 'groupOrder',
                component:  ()=>import("@/pages/Center/groupOrder"),
            },
            //重定向，项目初始页面首页
            {
                path: '/center',
                redirect: '/center/myOrder',

            }
        ]
    },


    //重定向，项目初始页面定位到首页
    {
        path: '*',
        redirect: '/home'
    }


]